﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DeviceSync
{
	public partial class LoginForm : Form
	{
		public LoginForm(string msg)
		{
			InitializeComponent();

			if (msg != null)
				label1.Text = msg;
		}

		private void LoginForm_Closing(object sender, CancelEventArgs e)
		{
			if (this.DialogResult == DialogResult.OK)
			{
				if (usernameText.Text.Length == 0 || passwordText.Text.Length == 0)
				{
					MessageBox.Show("Specify username and password");
					e.Cancel = true;
				} else
					Program.loginDets = new LoginDetails { Username = usernameText.Text.Trim(), Password = passwordText.Text };
			}
		}

		public void HideCancel()
		{
			menuItem1.Enabled = false;
		}

		private void menuItem1_Click(object sender, EventArgs e)
		{
			this.DialogResult = DialogResult.Cancel;
		}

		private void menuItem2_Click(object sender, EventArgs e)
		{
			Application.Exit();
		}
	}
}